{% extends 'base.html' %}
{% block content %}
  <h2 class="fw-bold mb-2">{{ theme.title }}</h2>
  <p class="text-muted mb-4">{{ theme.description }}</p>
  <div class="accordion" id="roundsAccordion">
    {% for round in theme.rounds %}
      <div class="accordion-item mb-3">
        <h2 class="accordion-header" id="heading{{ loop.index }}">
          <button class="accordion-button {% if not loop.first %}collapsed{% endif %}" type="button" data-bs-toggle="collapse" data-bs-target="#collapse{{ loop.index }}" aria-expanded="{{ 'true' if loop.first else 'false' }}" aria-controls="collapse{{ loop.index }}">
            <span class="me-2">{{ round.title }}</span>
            <span class="badge bg-light text-dark ms-2">每人最多 {{ round.max_votes_per_user }} 票</span>
          </button>
        </h2>
        <div id="collapse{{ loop.index }}" class="accordion-collapse collapse {% if loop.first %}show{% endif %}" aria-labelledby="heading{{ loop.index }}" data-bs-parent="#roundsAccordion">
          <div class="accordion-body">
            <p class="mb-2">{{ round.description }}</p>
            <ul class="mb-2 ps-3">
              {% for opt in round.options %}
                <li>{{ opt.label }}</li>
              {% endfor %}
            </ul>
            <div class="mb-2">
              <span class="badge bg-info text-dark ms-1">结果公开：{{ '是' if round.public_result else '否' }}</span>
              <span class="badge ms-2 px-3 py-2"
                style="box-shadow: 0 0 8px 2px {% if round.time_status == 'active' %}#45d19e{% else %}#ff6b6b{% endif %}; color: {% if round.time_status == 'active' %}#228b22{% else %}#c0392b{% endif %}; background: #f8f9fa; font-weight: 500;">
                投票时间：{{ round.start_time[:16] }} ~ {{ round.end_time[:16] }}
              </span>
            </div>
            <div class="d-flex gap-2 mt-2">
              <a href="{{ url_for('vote', theme_id=theme.id, round_id=round.id) }}" class="btn btn-primary btn-sm rounded-pill px-4">进入投票</a>
              {% if round.public_result %}
                <a href="{{ url_for('vote_result', theme_id=theme.id, round_id=round.id) }}" class="btn btn-outline-success btn-sm rounded-pill px-4">查看结果</a>
              {% endif %}
            </div>
          </div>
        </div>
      </div>
    {% endfor %}
  </div>
{% endblock %}
